import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MDMAuthModule } from './modules/mdmAuth/mdmAuth.module';
import { UserModule } from './modules/user/user.module';
import { User } from './entities/user.entity';
import { HRMModule } from './modules/hrm/hrm.module';
import { CityModule } from './modules/filters/city/city.module';
import { OrgModule } from './modules/filters/org/org.module';
import { PositionModule } from './modules/filters/position/position.module';
import { CronModule } from './modules/cron/cron.module';
import { ScheduleModule } from '@nestjs/schedule';
import { MeModule } from './modules/me/me.module';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: process.env.POSTGRES_HOST,
      port: Number(process.env.POSTGRES_PORT),
      username: process.env.POSTGRES_USER,
      password: process.env.POSTGRES_PASSWORD,
      database: process.env.POSTGRES_DATABASE,
      entities: [User],
      synchronize: false,
    }),
    ScheduleModule.forRoot(),
    MeModule,
    CronModule,
    MDMAuthModule,
    UserModule,
    HRMModule,
    CityModule,
    OrgModule,
    PositionModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
